<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: PortalLayoutBase.php 368 2010-02-06 20:23:50Z steen.rabol@gmail.com $
 *
 */

Prado::using('Application.Common.Web.UI.WebControls.PPLayoutControl');
Prado::using('Application.Common.Data.PortalConfigRecord');

class PortalLayoutBase extends TTemplateControl
{
	private $_layoutname;
	private $_type = 1;

	/**
	* 	Template types:
	*	0	= system types, should not be used for users
	*	1	= normal
	*/

	public function setName($p_name)
	{
		$this->_layoutname	= $p_name;
	}

	public function getName()
	{
		return $this->_layoutname != "" ? $this->_layoutname : get_class($this);
	}

	public function getType()
	{
		return $this->_type;
	}

	public function setType($p_type)
	{
		return $this->_type = $p_type;
	}

	public function getMetaKeywords()
	{
		$keywords = "";
		if($this->Page->PageRow)
		{
			$keywords = $this->Page->PageRow->metakeywords;
		}
		if($keywords == null)
		{
			$pcr = PortalConfigRecord::finder()->findByname('metaseo_metakeywords');
			if($pcr)
			{
				$keywords = $pcr->value;
			}
		}

		return $keywords;
	}

	public function getMetaDescription()
	{
		$description	= "";

		if($this->Page->PageRow)
		{
			$description = $this->Page->PageRow->metadescription;
		}
		
		if($description == null)
		{
			$pcr = PortalConfigRecord::finder()->findByname('metaseo_metadescription');
			if($pcr)
			{
				$description = $pcr->value;
			}
		}

		return $description;
	}

	public function getPageTitle()
	{
		$title	= $this->Application->Parameters['SiteTitle'];
		if($this->Page->PageRow)
		{
			$title .= " - " .$this->Page->PageRow->displayname;
		}

		return $title;
	}
}
?>